***Terrorism Survey
***Survey implemented by Dyanata from 1/24/2020 to 1/27/2020

*Use data file: Dynata1RepData.dta

***************
*Demographics**
***************
*Note: tables for these recoded variables are the basis for the corresponding sample demographic information Appendix Table 1 and sample information in the Supplemental Materials


*Partisanship
*Q75 Generally speaking, do you think of yourself as a Republican, Democrat, Independent, or what?
*Republican  (1) 
*Democrat  (2) 
*Independent  (3) 
*Other party (specify)  (4) 

*Q76 Would you call yourself a strong Democrat or not a very strong Democrat?
*Strong  (1) 
*Not very strong  (2) 

*Q77 Would you call yourself a strong Republican or not a very strong Republican?
*Strong  (1) 
*Not very strong  (2) 

*Q78 Do you think of yourself as closer to the Republican Party or the Democratic Party?
*Closer to Republican  (1) 
*Neither  (2) 
*Closer to Democratic  (3) 

tab Q75
tab Q76
tab Q77
tab Q78

gen party7=.
replace party=1 if Q76==1
replace party=2 if Q76==2
replace party=3 if Q78==3
replace party=4 if Q78==2
replace party=5 if Q78==1
replace party=6 if Q77==2
replace party=7 if Q77==1
tab party7

gen party2=.
replace party2=0 if party7==1
replace party2=0 if party7==2
replace party2=0 if party7==3
replace party2=1 if party7==5
replace party2=1 if party7==6
replace party2=1 if party7==7
tab party2
label define party2 0 "Democrat" 1 "Republican"
label values party2 party2
tab party2

gen party3=.
replace party3=0 if party7==1
replace party3=0 if party7==2
replace party3=0 if party7==3
replace party3=1 if party7==4
replace party3=2 if party7==5
replace party3=2 if party7==6
replace party3=2 if party7==7
tab party3
label define party3 0 "Democrat" 1 "Independent" 2 "Republican"
label values party3 party3
tab party3

*Ideology
*Q79 Where would you place yourself on the following scale regarding your political views?
*1 extremely liberal to 7 extremely conservative
tab Q79
gen ideo=Q79
tab ideo


*Q82 What is your gender?
*Male  (1) 
*Female  (2) 
*Other  (3) 
tab Q82
gen gender=.
replace gender=1 if Q82==1
replace gender=2 if Q82==2
replace gender=3 if Q82==3
tab gender
label define gender 1 "Male" 2 "Female" 3"Other"
label values gender gender
tab gender

gen gender2=gender
replace gender2=. if gender==3
tab gender2
label define gender2 1 "Male" 2 "Female"
label values gender2 gender2
tab gender2

*Education
*Q83 What is the highest level of education you have completed?
tab Q83
gen edu=Q83
tab edu
tabstat edu, stats (p50)

*Age
*Q84 What is your age?
tab Q84
gen age=Q84
replace age=. if Q84==999
tab age
mean age

*Income
*Q85 What is your estimate of your annual household income (before taxes)?
tab Q85
gen income=Q85
tab income


*Race
*Q80 Are you Spanish, Hispanic, or Latino or none of these?
*Yes  (1) 
*None of these  (0) 
tab Q80
*Q81 Choose one or more races that you consider yourself to be. Check all that apply. 
*White  (1) 
*Black or African American  (2) 
*American Indian or Alaskan Native  (3) 
*Asian  (4) 
*Native Hawaiian or Pacific Islander  (5) 
*Other (please specify)  (6) 
tab Q81

*3 category race, non-hispanic white, non-hispanic black, other
gen race3=.
replace race3=0 if Q80==0 & Q81=="1"
replace race3=1 if Q80==0 & Q81=="2"
replace race3=2 if Q80==1 & Q81=="1"
replace race3=2 if Q80==1 & Q81=="2"
replace race3=2 if Q81=="1,2"
replace race3=2 if Q81=="1,2,3"
replace race3=2 if Q81=="1,2,3,5"
replace race3=2 if Q81=="1,2,6"
replace race3=2 if Q81=="1,3"
replace race3=2 if Q81=="1,4"
replace race3=2 if Q81=="1,5"
replace race3=2 if Q81=="1,6"
replace race3=2 if Q81=="2,4"
replace race3=2 if Q81=="3"
replace race3=2 if Q81=="3,4"
replace race3=2 if Q81=="4"
replace race3=2 if Q81=="5"
replace race3=2 if Q81=="6"
tab race3
label define race3 0 "White" 1 "Black" 2 "Other"
label values race3 race3
tab race3


*Q94 How worried are you about being the victim of a crime? 
*1 not worried at all, 7 extremely worried
tab Q94
gen worry=Q94
tab worry


*Authoritarianism
*Q99 Please tell us which one you think is more important for a child to have: independence or respect for elders?
*Independence  (1) 
*Respect for elders  (2) 
tab Q99
gen auth1=.
replace auth1=0 if Q99==1
replace auth1=1 if Q99==2
tab auth1

*Q100 Please tell us which one you think is more important for a child to have: obedience or self reliance? 
*Obedience  (1) 
*Self reliance  (2) 
tab Q100
gen auth2=.
replace auth2=0 if Q100==2
replace auth2=1 if Q100==1
tab auth2

*Q101 Please tell us which one you think is more important for a child to have: curiosity or good manners? 
*Curiosity  (1) 
*Good manners  (2) 
tab Q101
gen auth3=.
replace auth3=0 if Q101==1
replace auth3=1 if Q101==2
tab auth3

*Q102 Please tell us which one you think is more important for a child to have: being considerate or well behaved? 
*Considerate  (1) 
*Well behaved  (2) 
tab Q102
gen auth4=.
replace auth4=0 if Q102==1
replace auth4=1 if Q102==2
tab auth4

gen auth= auth1+auth2+auth3+auth4
tab auth

*********************************************
*Terrorism Stuff
*********************************************
tab TerrorGroup
gen terror=.
replace terror=0 if TerrorGroup=="TerrControl"
replace terror=1 if TerrorGroup=="TerrIF"
replace terror=2 if TerrorGroup=="TerrWN"
tab terror
label define terror 0 "Control" 1 "Islamic Fundamentalist" 2 "White Nationalist"
label values terror terror
tab terror


*Q56 Should people suspected of terrorist involvement be banned from making public speeches?
*Q64 Should Islamic Fundamentalists suspected of terrorist involvement be banned from making public speeches?
*Q68 Should White Nationalists suspected of terrorist involvement be banned from making public speeches?
*Yes = 1
*No = 0

gen speech=.
replace speech=1 if Q56==1
replace speech=1 if Q64==1
replace speech=1 if Q68==1
replace speech=0 if Q56==0
replace speech=0 if Q64==0
replace speech=0 if Q68==0
tab speech
label define speech 0 "No" 1 "Yes"
label values speech speech
tab speech

**Info for Table 1
*Dem
tab speech terror if(party2==0), col
prtest speech if(terror==0 & party2==0 | terror==1 & party2==0), by(terror)
prtest speech if(terror==0 & party2==0 | terror==2 & party2==0), by(terror)
*Rep
tab speech terror if(party2==1), col
prtest speech if(terror==0 & party2==1 | terror==1 & party2==1), by(terror)
prtest speech if(terror==0 & party2==1 | terror==2 & party2==1), by(terror)
*Full Model for Supplementals
logit speech i.terror i.party2 i.gender2 i.race3 edu age income auth worry i.terror##i.party2, robust
*outreg2  using ModelsDi.doc , 2aster replace ctitle(Ban Speech) label 
margins, dydx(i.terror) at(party2=(0 1)) vsquish
marginsplot, scheme(s1mono)  xlab(-.25 " " 0 "Democrat" 1 "Republican" 1.25 " ", ) title("Effect on Probability of Support for Banning Speech (Dynata 1)") yline(0,lpattern(dot))  xtitle("Partisanship", margin(medium)) ytitle("Effect on Probability of Support", margin(medium)) plot(,label("Islamic Fundamentalist" "White Nationalist"))
*graph export SpeechParty.pdf, replace

*Predicted Probabilities for Table 1
margins i.terror, at(party2=(0 1)) vsquish


*Q54 If a person is suspected of being a terrorist, should the government be allowed to monitor their phone calls without obtaining a warrant?
*Q60 If a person is suspected of being an Islamic Fundamentalist terrorist, should the government be allowed to monitor their phone calls without obtaining a warrant?
*Q66 If a person is suspected of being a White Nationalist terrorist, should the government be allowed to monitor their phone calls without obtaining a warrant?
*Yes = 1
*No = 0
tab Q54
tab Q60
tab Q66

gen monitor=.
replace monitor=1 if Q54==1
replace monitor=1 if Q60==1
replace monitor=1 if Q66==1
replace monitor=0 if Q54==0
replace monitor=0 if Q60==0
replace monitor=0 if Q66==0
tab monitor
label define monitor 0 "No" 1 "Yes"
label values monitor monitor
tab monitor

**Info for Table 1
*Dem
tab monitor terror if(party2==0), col
prtest monitor if(terror==0 & party2==0 | terror==1 & party2==0), by(terror)
prtest monitor if(terror==0 & party2==0 | terror==2 & party2==0), by(terror)
*Rep
tab monitor terror if(party2==1), col
prtest monitor if(terror==0 & party2==1 | terror==1 & party2==1), by(terror)
prtest monitor if(terror==0 & party2==1 | terror==2 & party2==1), by(terror)
*Full Model for Supplementals
logit monitor i.terror i.party2 i.gender2 i.race3 edu age income auth worry i.terror##i.party2, robust
*outreg2 using ModelsDi.doc, append ctitle(Monitor) label 
margins, dydx(i.terror) at(party2=(0 1)) vsquish
marginsplot, scheme(s1mono)  xlab(-.25 " " 0 "Democrat" 1 "Republican" 1.25 " ", ) title("Effect on Probability of Support for Monitoring Phone (Dynata 1)") yline(0,lpattern(dot))  xtitle("Partisanship", margin(medium)) ytitle("Effect on Probability of Support", margin(medium)) plot(,label("Islamic Fundamentalist" "White Nationalist"))
*graph export MonitorParty.pdf, replace

*Predicted Probabilities for Table 1
margins i.terror, at(party2=(0 1)) vsquish


*Q55 Should the government shut down social media accounts belonging to someone suspected of being a terrorist?
*Q61 Should the government shut down social media accounts belonging to someone suspected of being an Islamic Fundamentalist terrorist?
*Q67 Should the government shut down social media accounts belonging to someone suspected of being a White Nationalist terrorist?
*Yes = 1
*No = 2

gen socialmed=.
replace socialmed=1 if Q55==1
replace socialmed=1 if Q61==1
replace socialmed=1 if Q67==1
replace socialmed=0 if Q55==2
replace socialmed=0 if Q61==2
replace socialmed=0 if Q67==2
tab socialmed
tab socialmed
label define socialmed 0 "No" 1 "Yes"
label values socialmed socialmed
tab socialmed

**Info for Table 1
*Dem
tab socialmed terror if(party2==0), col
prtest socialmed if(terror==0 & party2==0 | terror==1 & party2==0), by(terror)
prtest socialmed if(terror==0 & party2==0 | terror==2 & party2==0), by(terror)
*Rep
tab socialmed terror if(party2==1), col
prtest socialmed if(terror==0 & party2==1 | terror==1 & party2==1), by(terror)
prtest socialmed if(terror==0 & party2==1 | terror==2 & party2==1), by(terror)
*Full Model for Supplementals
logit socialmed i.terror i.party2 i.gender2 i.race3 edu age income auth worry i.terror##i.party2, robust
*outreg2 using ModelsDi.doc, append ctitle(Social Media) label 
margins, dydx(i.terror) at(party2=(0 1)) vsquish
marginsplot, scheme(s1mono)  xlab(-.25 " " 0 "Democrat" 1 "Republican" 1.25 " ", ) title("Effect on Prob. of Support for Shutting Down Social Media (Dynata 1)") yline(0,lpattern(dot))  xtitle("Partisanship", margin(medium)) ytitle("Effect on Probability of Support", margin(medium)) plot(,label("Islamic Fundamentalist" "White Nationalist"))
*graph export MediaParty.pdf, replace
*Predicted Probabilities for Table 1
margins i.terror, at(party2=(0 1)) vsquish


*Q57 Should the government be allowed to hold a person suspected of being a terrorist for an unlimited amount of time?
*Q62 Should the government be allowed to hold an Islamic Fundamentalist suspected of plotting a terror attack for an unlimited amount of time?
*Q69 Should the government be allowed to hold a White Nationalist suspected of plotting a terror attack for an unlimited amount of time?
*Yes = 1
*No = 0

gen hold=.
replace hold=1 if Q57==1
replace hold=1 if Q62==1
replace hold=1 if Q69==1
replace hold=0 if Q57==0
replace hold=0 if Q62==0
replace hold=0 if Q69==0
tab hold
label define hold 0 "No" 1 "Yes"
label values hold hold
tab hold

**Info for Table 1
*Dem
tab hold terror if(party2==0), col
prtest hold if(terror==0 & party2==0 | terror==1 & party2==0), by(terror)
prtest hold if(terror==0 & party2==0 | terror==2 & party2==0), by(terror)
*Rep
tab hold terror if(party2==1), col
prtest hold if(terror==0 & party2==1 | terror==1 & party2==1), by(terror)
prtest hold if(terror==0 & party2==1 | terror==2 & party2==1), by(terror)
*Full Model for Supplementals
logit hold i.terror i.party2 i.gender2 i.race3 edu age income auth worry i.terror##i.party2, robust
*outreg2 using ModelsDi.doc, append ctitle(Hold) label 
margins, dydx(i.terror) at(party2=(0 1)) vsquish
marginsplot, scheme(s1mono)  xlab(-.25 " " 0 "Democrat" 1 "Republican" 1.25 " ", ) title("Effect on Prob. of Support for Holding Indefinitely (Dynata 1)") yline(0,lpattern(dot))  xtitle("Partisanship", margin(medium)) ytitle("Effect on Probability of Support", margin(medium)) plot(,label("Islamic Fundamentalist" "White Nationalist"))
*graph export HoldParty.pdf, replace
*Predicted Probabilities for Table 1
margins i.terror, at(party2=(0 1)) vsquish



***** 4 item index
tab speech
tab monitor
tab socialmed
tab hold

gen addindex= speech + monitor + socialmed + hold
tab addindex

gen avgindex= addindex/4
tab avgindex

**Info for Table 1
*Dem
tabstat avgindex if(party2==0), by(terror) stats(mean sem n)
ttest avgindex if(terror==0 & party2==0 | terror==1 & party2==0), by(terror)
ttest avgindex  if(terror==0 & party2==0 | terror==2 & party2==0), by(terror)
*Rep
tabstat avgindex if(party2==1), by(terror) stats(mean sem n)
ttest avgindex if(terror==0 & party2==1 | terror==1 & party2==1), by(terror)
ttest avgindex  if(terror==0 & party2==1 | terror==2 & party2==1), by(terror)
*Full Model for Table 2 and Supplementals
regress avgindex i.terror i.party2 i.gender2 i.race3 edu age income auth worry i.terror##i.party2, robust
*outreg2 using ModelsDi.doc, append ctitle(Index) label 
*Figure 1
margins, dydx(i.terror) at(party2=(0 1)) vsquish
marginsplot, scheme(s1mono)  xlab(-.25 " " 0 "Democrat" 1 "Republican" 1.25 " ", ) title("Effect on Support for Restrictions (Index, Dynata 1)") yline(0,lpattern(dot))  xtitle("Partisanship", margin(medium)) ytitle("Effect on Support for Restrictions", margin(medium)) plot(,label("Islamic Fundamentalist" "White Nationalist"))
*graph export AverageIndex.pdf, replace

**************************************
*Analyses for Supplemental Materials**
**************************************

*Models with no controls; just interaction between party and treatment
logit speech i.terror i.party2  i.terror##i.party2
*outreg2 using NoControlModels.doc, replace ctitle(Ban Speech) label
logit monitor i.terror i.party2  i.terror##i.party2
*outreg2 using NoControlModels.doc, append ctitle(Monitor) label
logit socialmed i.terror i.party2  i.terror##i.party2
*outreg2 using NoControlModels.doc, append ctitle(Social Media) label
logit hold i.terror i.party2  i.terror##i.party2
*outreg2 using NoControlModels.doc, append ctitle(Hold) label
regress avgindex i.terror i.party2  i.terror##i.party2, robust
*outreg2 using NoControlModels.doc, append ctitle(Index) label

*Full Models (with controls) with partisanship as 3 categories: Democrat, “Pure” Independent, Republican 
logit speech i.terror i.party3 i.gender2 i.race3 edu age income auth worry i.terror##i.party3, robust
*outreg2 using ModelsParty3.doc, replace ctitle(Ban Speech) label 
logit monitor i.terror i.party3 i.gender2 i.race3 edu age income auth worry i.terror##i.party3, robust
*outreg2 using ModelsParty3.doc, append ctitle(Monitor) label 
logit socialmed i.terror i.party3 i.gender2 i.race3 edu age income auth worry i.terror##i.party3, robust
*outreg2 using ModelsParty3.doc, append ctitle(Social Media) label 
logit hold i.terror i.party3 i.gender2 i.race3 edu age income auth worry i.terror##i.party3, robust
*outreg2 using ModelsParty3.doc, append ctitle(Hold) label 
regress avgindex i.terror i.party3 i.gender2 i.race3 edu age income auth worry i.terror##i.party3, robust
*outreg2 using ModelsParty3.doc, append ctitle(Index) label 


*Models with no controls or interactions for party; just average treatment effects
logit speech i.terror, robust
*outreg2 using ATEModels.doc, replace ctitle(Ban Speech) label
logit monitor i.terror, robust
*outreg2 using ATEModels.doc, append ctitle(Monitor) label 
logit socialmed i.terror, robust
*outreg2 using ATEModels.doc, append ctitle(Social Media) label 
logit hold i.terror, robust
*outreg2 using ATEModels.doc, append ctitle(Hold) label
regress avgindex i.terror, robust
*outreg2 using ATEModels.doc, append ctitle(Index) label


***Models to be corrected for multiple group comparisons. P-value to be multiplied by 6 for correction.
regress avgindex i.terror i.party2  i.terror##i.party2, robust pformat(%5.4f) 
regress avgindex i.terror i.party2 i.gender2 i.race3 edu age income auth worry i.terror##i.party2, robust pformat(%5.4f) 


